<template>
  <div>
    <n-modal
      v-model:show="props.showModal"
      :mask-closable="true"
      @update:show="$emit('CheckShowModal', false)"
      preset="dialog"
      title="确认"
      content="确认删除?"
      positive-text="确认"
      negative-text="取消"
      @positive-click="onPositiveClick"
      @negative-click="onNegativeClick"
    />
  </div>
</template>

<script lang="ts" setup>
import { defineProps, ref } from "vue";
import { DelChildren } from "@/api/children";
import { useMessage } from "naive-ui";
const emit = defineEmits(["CheckShowModal", "reloadpage"]);
const props = defineProps({
  showModal: {
    type: Boolean,
    default: false,
  },
  userId: {
    type: Number,
    default: "",
  },
});
const scId = ref();
const message = useMessage();
const onPositiveClick = () => {
  scId.value = props.userId;
  DelChildren(scId.value).then((res) => {
    if (res.data == 1) {
      emit("CheckShowModal", false);
      message.success("删除成功");
    } else {
      emit("CheckShowModal", false);
      message.success("删除失败");
    }
  });
};
const onNegativeClick = () => {
  emit("CheckShowModal", false);
};
</script>

<style scoped lang="scss"></style>
